package com.ikas.ai.server.module.appraise.enums;

/**
 * @author hu.bowei@ikasinfo.com
 * @date 2023-2-2 10:40:17
 * 评价综合结果分页列表查询
 * 90-100 优秀
 * 75-90 良好
 * 60-75 关注
 * 0-60 危险
 */
public enum ScoreLevelEnum {
    A("优秀", 90.0),
    B("良好", 75.0),
    C("关注", 60.0),
    D("危险", 0.0);


    ScoreLevelEnum(String desc, Double score) {
        this.desc = desc;
        this.score = score;
    }

    private String desc;
    private Double score;

    public String getDesc() {
        return desc;
    }

    public Double getScore() {
        return score;
    }

    public static String desc(Double score) {
        if (score < 0 || score > 100) {
            return ScoreLevelEnum.D.desc;
        }
        if (score >= 90) {
            return ScoreLevelEnum.A.desc;
        } else if (score >= 75 && score < 90) {
            return ScoreLevelEnum.B.desc;
        } else if (score >= 60 && score < 75) {
            return ScoreLevelEnum.C.desc;
        } else {
            return ScoreLevelEnum.D.desc;
        }
    }

    public static ScoreLevelEnum descWord(Double score) {
        if (score < 0 || score > 100) {
            return ScoreLevelEnum.D;
        }
        if (score >= 90) {
            return ScoreLevelEnum.A;
        } else if (score >= 75 && score < 90) {
            return ScoreLevelEnum.B;
        } else if (score >= 60 && score < 75) {
            return ScoreLevelEnum.C;
        } else {
            return ScoreLevelEnum.D;
        }
    }

    public static ScoreLevelEnum valueOfDesc(String desc) {
        for (ScoreLevelEnum item : ScoreLevelEnum.values()) {
            if (desc.equals(item.getDesc())) {
                return item;
            }
        }
        return ScoreLevelEnum.D;
    }

}
